#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e3,INF=0x7fffffff;
int n,m,head[MAXN*2+10],cnt,idx[MAXN*2+10],sum;
bool vis[MAXN];
struct edge
{
	int v,next,val;
}e[MAXN*MAXN*2+MAXN*4];
void addedge(int x,int y,int z)
{
	e[cnt]=(edge){y,head[x],z};
	head[x]=cnt++;
	return;
}
void bfs()
{
	memset(idx,0,sizeof(idx));
	queue<int>q;
	q.push(0);
	idx[0]=1;
	while(!q.empty())
	{
		int u=q.front();q.pop();
		for(int i=head[u];~i;i=e[i].next)
		{
			int v=e[i].v;
			if(idx[v]||!e[i].val)continue;
			idx[v]=idx[u]+1;
			q.push(v);
		}
	}
	return;
}
int dfs(int u,int _min)
{
	if(u==MAXN*2+1)return _min;
	int ret=0,k;
	for(int i=head[u];~i;i=e[i].next)
	{
		int v=e[i].v;
		if(idx[v]!=idx[u]+1||!e[i].val)continue;
		k=dfs(v,min(_min-ret,e[i].val));
		e[i].val-=k;
		e[i^1].val+=k;
		ret+=k;
		if(ret==_min)break;
	}
	return ret;
}
int dinic()
{
	int ret=0;
	while(true)
	{
		bfs();
		if(!idx[MAXN*2+1])break;
		ret+=dfs(0,INF);
	}
	return ret;
}
bool check(int i,int j)
{
	if((int)sqrt(i+j)*(int)sqrt(i+j)==i+j)return true;
	return false;
}
int main()
{
	memset(head,-1,sizeof(head));
	scanf("%d",&n);
	while(true)
	{
		++m;++sum;
		for(int i=1;i<m;++i)
			if(check(m,i))
			{
				addedge(i,m+MAXN,1);
				addedge(m+MAXN,i,0);
			}
		addedge(0,m,1);
		addedge(m,0,0);
		addedge(m+MAXN,MAXN*2+1,1);
		addedge(MAXN*2+1,m+MAXN,0);
		sum-=dinic();
		if(sum>n)break;
	}
	printf("%d\n",m-1);
	memset(idx,0,sizeof(idx));
	for(int i=1;i<m;++i)
	{
		for(int j=head[i];~j;j=e[j].next)
		{
			if(e[j].val)continue;
			idx[i]=e[j].v-MAXN;
			break;
		}
	}
	for(int i=1;i<m;++i)
	{
		if(vis[i])continue;
		int j=i;
		while(j!=-MAXN)
		{
			vis[j]=true;
			printf("%d ",j);
			j=idx[j];
		}
		puts("");
	}
	return 0;
}
